var simSpace = {
		minx : 0,
		miny : 0,
		maxx : 150,
		maxy : 70
};
var screenSpace = {
		minx : 0,
		miny : 0,
		maxx : window.innerWidth * 0.80,
		maxy : window.innerHeight * 0.80
};
var converter = new UnitsConverter(simSpace, screenSpace);

billboard = new Billboard(12,3);
var textString =[
	"            "+
	"     HELLO! "+
	"            ",
	
	"THIS IS A   "+
	"            "+
	"D E M O     ",
	
	"OF THE      "+
	"  AMAAAAZING"+
	"            ",

	"FLYING%%%%%%"+
	"%%%%%%%%%%%%"+
	"%%%LETTERS!!",

	"$$$$$$$$$$$$"+
	" AWESOME! $$"+
	"$$$$$$$$$$$$"
];
for(var i=0;i<textString.length;i++){
	billboard.addString(textString[i]);
}

var particles = billboard.getParticles();

var startTime = new Date().getTime();
function t(){
	return ((new Date().getTime()) - startTime) / 1000.0;
}

function startAnimation() {
	for (var i = 0; i < particles.length; i++) {
		var p = particles[i];
		p.element = document.createElement('div');
		e = p.element;
		e.setAttribute('id', 'particle' + i);
		e.setAttribute('class', 'particle');
		document.body.appendChild(e);
	}
	
	setInterval("refreshParticles()", 20);
}

function refreshParticles(){
	for(var i=0;i<particles.length;i++){
		var p = particles[i];
		var e = p.element;
		p.getYPosition(t());
		var coords = converter.convert({x:p.x, y:p.y});
		e.setAttribute('style','top:'+coords.y+';left:'+coords.x);
		if(p.released == true)
			e.setAttribute('style','display:none');
	}
}
